package com.example.appkcsj.slice;

import com.example.appkcsj.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.Image;

public class sixthAbilitySlice extends AbilitySlice implements Component.ClickedListener {
    Button but,but1,but2,but3,but4;
    Image m;
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_sixth);
        but= (Button) findComponentById(ResourceTable.Id_but8);
        but.setClickedListener(this);
        but1= (Button) findComponentById(ResourceTable.Id_but7);
        but1.setClickedListener(this);
        but2= (Button) findComponentById(ResourceTable.Id_but9);
        but2.setClickedListener(this);
        but3= (Button) findComponentById(ResourceTable.Id_butf);
        but3.setClickedListener(this);
        but4= (Button) findComponentById(ResourceTable.Id_but);
        but4.setClickedListener(this);
        m=(Image) findComponentById(ResourceTable.Id_image6);
        m.setClickedListener(this);
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }

    @Override
    public void onClick(Component component) {
        if(component == but){
            Intent n=new Intent();
            Operation operation=new Intent.OperationBuilder()
                    .withDeviceId("")
                    .withBundleName("com.example.appkcsj")//跳转到哪个应用
                    .withAbilityName("com.example.appkcsj.maddAbility")//要跳转的包名
                    .build();//将上面的信息打包
            n.setOperation(operation);
            startAbility(n);
        }
        else if(component == but1){
            Intent n=new Intent();
            Operation operation=new Intent.OperationBuilder()
                    .withDeviceId("")
                    .withBundleName("com.example.appkcsj")//跳转到哪个应用
                    .withAbilityName("com.example.appkcsj.mdeleteAbility")//要跳转的包名
                    .build();//将上面的信息打包
            n.setOperation(operation);
            startAbility(n);
        }
        else if(component == but2){
            Intent n=new Intent();
            Operation operation=new Intent.OperationBuilder()
                    .withDeviceId("")
                    .withBundleName("com.example.appkcsj")//跳转到哪个应用
                    .withAbilityName("com.example.appkcsj.mupdateAbility")//要跳转的包名
                    .build();//将上面的信息打包
            n.setOperation(operation);
            startAbility(n);
        }
        else if(component == but3){
            Intent n=new Intent();
            Operation operation=new Intent.OperationBuilder()
                    .withDeviceId("")
                    .withBundleName("com.example.appkcsj")//跳转到哪个应用
                    .withAbilityName("com.example.appkcsj.thirdAbility")//要跳转的包名
                    .build();//将上面的信息打包
            n.setOperation(operation);
            startAbility(n);
        }
        else if(component == but4){
            Intent n=new Intent();
            Operation operation=new Intent.OperationBuilder()
                    .withDeviceId("")
                    .withBundleName("com.example.appkcsj")//跳转到哪个应用
                    .withAbilityName("com.example.appkcsj.xsAbility")//要跳转的包名
                    .build();//将上面的信息打包
            n.setOperation(operation);
            startAbility(n);
        }
        else if(component == m){
            Intent n=new Intent();
            Operation operation=new Intent.OperationBuilder()
                    .withDeviceId("")
                    .withBundleName("com.example.appkcsj")//跳转到哪个应用
                    .withAbilityName("com.example.appkcsj.MainAbility")//要跳转的包名
                    .build();//将上面的信息打包
            n.setOperation(operation);
            startAbility(n);
        }
    }
}
